import request from '@/utils/request';

export function getArticleList(params: { pageNum: number; pageSize: number }) {
  return request({
    url: '/api/articles',
    method: 'get',
    params
  });
}

export function getArticleDetail(id: number) {
  return request({
    url: `/api/articles/${id}`,
    method: 'get'
  });
}

export function getArticlesByCategory(categoryId: number, pageNum: number, pageSize: number) {
  return request({
    url: `/api/articles/category/${categoryId}`,
    method: 'get',
    params: { pageNum, pageSize }
  });
}

// 获取用户自己的文章
export function getUserArticles(params: { pageNum: number; pageSize: number; status?: number }) {
  return request({
    url: '/api/user/articles',
    method: 'get',
    params
  });
}

// 创建文章
export function createArticle(data: any) {
  return request({
    url: '/api/articles',
    method: 'post',
    data
  });
}

// 更新文章
export function updateArticle(id: number, data: any) {
  return request({
    url: `/api/articles/${id}`,
    method: 'put',
    data
  });
}

// 删除文章
export function deleteArticle(id: number) {
  return request({
    url: `/api/articles/${id}`,
    method: 'delete'
  });
} 